#!/usr/bin/env python
import paramiko

ip = '192.168.10.67'
user = 'root'
passwd = '123456'
paramiko.util.log_to_file('cmd_log.log') #记录日志

ssh = paramiko.SSHClient()
ssh.load_system_host_keys() #获取客户端的host_keys，默认路径~/.ssh/known_hosts,非默认需要指定
ssh.connect(hostname=ip,username=user,password=passwd) #ssh连接
stdin,stdout,stderr = ssh.exec_command('free -m') #执行命令
print(stdout.read().decode('utf-8')) 打印结果
ssh.close()
